package com.hh.config;

import com.hh.constant.QueueConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author 辉辉 2022/8/20 14:25
 */
@Configuration
public class MqSendMsgConfig {
    /**
     * queue
     *
     * @return
     */
    @Bean
    public Queue sendSmsQueue() {
        return new Queue(QueueConstant.PHONE_SEND_QUEUE);
    }

    /**
     * 绑定一下
     * @return
     */
    @Bean
    public DirectExchange sendSmsEx() {
        return new DirectExchange(QueueConstant.PHONE_SEND_EX);
    }

    /**
     * 绑定
     * @return
     */
    @Bean
    public Binding sendSmsBind() {
        return BindingBuilder.bind(sendSmsQueue()).to(sendSmsEx()).with(QueueConstant.PHONE_SEND_KEY);
    }

    //--------上面的是短信的配置 下面的是微信公众号的配置

    /**
     * queue
     *
     * @return
     */
    @Bean
    public Queue wxMsgQueue() {
        return new Queue(QueueConstant.WECHAT_SEND_QUEUE);
    }

    /**
     * 绑定一下
     * @return
     */
    @Bean
    public DirectExchange wxMsgEx() {
        return new DirectExchange(QueueConstant.WECHAT_SEND_EX);
    }

    /**
     * 绑定
     * @return
     */
    @Bean
    public Binding wxMsgBind() {
        return BindingBuilder.bind(wxMsgQueue()).to(wxMsgEx()).with(QueueConstant.WECHAT_SEND_KEY);
    }
}
